﻿using System;
namespace Calculator.Xroad.Eu {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="Variables", Namespace="http://calculator.x-road.eu", Target=typeof(Variables))]
    public class VariablesSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected Variables clazz;
        
        public VariablesSerializer(Variables clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXmlAttributes(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXmlAttributes(Writer);
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("VarX");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.VarX))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("VarY");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.VarY))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXmlAttributes(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXmlAttributes(Reader);
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="VarX") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>Variables>VarX");
                }
                clazz.VarX = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("VarX")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>Variables>VarX", Reader.LocalName);
            }
            if (Reader.LocalName=="VarY") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>Variables>VarY");
                }
                clazz.VarY = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("VarY")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>Variables>VarY", Reader.LocalName);
            }
        }
    }
}
